<template>
    <!-- 申请弹窗 -->
    <a-modal
        :title="title"
        :width="width"
        :visible="visible"
        :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
        @ok="handleOk"
        @cancel="handleCancel"
        destroyOnClose
    >
        <VolunteerTeam ref="VolunteerTeam" :editableFiexd="editableFiexd" :showBuildTime="showBuildTime" :canDismiss="canDismiss" :editable="editable" :dataId="dataId" v-model="formData"></VolunteerTeam>
    </a-modal>
</template>

<script>
import { setVolunteerTeam} from '@/api/api'
import VolunteerTeam from './VolunteerTeam'
export default {
    name:'VolunteerTeamModal',
    components:{
        VolunteerTeam
    },
    data(){
        return {
            title:'',
            width:800,
            visible: false,
            disableSubmit: false,
            showBuildTime: false,
            editable:true,
            canDismiss:false,
            formData:{},
            editableFiexd:{},
            workflowModel:{
                operation: "start"
            },
            dataId:'',
            successTxt:''
        }
    },
    methods:{
        add (data) {

            this.visible = true
            this.showBuildTime = true
            this.$nextTick(()=>{
                this.$refs.VolunteerTeam.add({
                    actStatus:10
                })
            })
        },
        apply(data,editableFiexd){
            this.visible = true
            this.showBuildTime = false
            this.editableFiexd = Object.assign({directorId:true},editableFiexd)
            this.$nextTick(()=>{
                this.$refs.VolunteerTeam.apply(data)
            })
        },
        edit (record,editableFiexd) {
            this.visible = true
            this.showBuildTime = true
            if(record.actStatus==10){
                this.canDismiss = true
            }else{
                this.canDismiss = false
            }
            this.editableFiexd = {directorId:false}
            this.$nextTick(()=>{
                this.$refs.VolunteerTeam.edit(record)
            })

        },
        review (record) {
            this.title = '查看'
            this.visible=true
            this.editable = false
            // this.dataId =record.id
            this.formData = record
            this.disableSubmit = true
        },
        close () {
            this.$emit('close');
            this.title = ''
            this.editable = true
            this.formData = {}
            this.editableFiexd = {}
            this.disableSubmit = false
            this.showBuildTime = false
            this.canDismiss = false
            this.visible = false;
        },
        handleOk () {
            this.$refs.VolunteerTeam.submitForm().then(res=>{
                this.$emit('ok');
                this.visible = false;
            })
        },
        handleCancel () {
            this.close()
        }
    }
}
</script>

<style>

</style>